package com.serverTechnology.teamsGroups.controller;


import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData;
import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData;
import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import com.serverTechnology.teamsGroups.entity.dto.LocationTypeAddDto;
import com.serverTechnology.teamsGroups.entity.dto.TeLocationTypeDto;
import com.serverTechnology.teamsGroups.entity.vo.TeLocationTypeVo;
import com.serverTechnology.teamsGroups.service.LocationTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 库位类型 前端控制器
 * </p>
 *
 * @author 王凯炫
 * @since 2024-08-05
 */
@RestController
@RequestMapping("/location/type")
@ApiResource(name = "库位类型接口")
@Api(tags = "库位类型管理")
public class TeLocationTypeController {

    @Resource(name = "teLocationTypeServiceImpl")
    private LocationTypeService locationTypeService;

    /**
     * 添加库位类型
     * @param locationTypeAddDto
     * @return
     */
    @PostMapping("/add")
    @ApiOperation(value = "添加修改库位类型")
    public ResponseData addTeLocationType(@RequestBody @Validated LocationTypeAddDto locationTypeAddDto){
        locationTypeService.addTeLocationType(locationTypeAddDto);
        return new SuccessResponseData<>();
    }

    /**
     * 查询库位类型详情
     * @param id
     * @return
     */
    @GetMapping("/sel")
    @ApiOperation(value = "查询库位类型详情")
    public ResponseData<TeLocationTypeVo> sel(Long id){
        return new SuccessResponseData<>(locationTypeService.getByIds(id));
    }

    /**
     * 查询库位类型列表
     * @param locationTypeDto
     * @return
     */
    @PostMapping("/page")
    @ApiOperation(value = "查询库位类型列表")
    public ResponseData<PageResult<TeLocationTypeVo>> pages(TeLocationTypeDto locationTypeDto){
        return new SuccessResponseData<>(locationTypeService.pages(locationTypeDto));
    }

    /**
     * 删除库位类型
     * @param id
     * @return
     */
    @GetMapping("/del")
    @ApiOperation(value = "删除库位类型")
    public ResponseData dels(Long id){
        locationTypeService.dels(id);
        return new SuccessResponseData<>();
    }


}
